package com.tz.web.admstar;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.tz.bean.Star;
import com.tz.bean.TzParams;
import com.tz.service.user.IStarService;

@Controller
@RequestMapping("/admin/star")
public class StarController {

	@Autowired
	private IStarService starService;
	
	@RequestMapping("/list")
	public String courseList(TzParams params){
		return "star/list";
	}
	
	@RequestMapping("/template")
	public ModelAndView template(TzParams params){
		ModelAndView modelAndView = new ModelAndView();
		params.setIsDelete(1);
		List<Star> stars = starService.find(params);
		int count = starService.count(params);
		modelAndView.setViewName("/star/template");
		modelAndView.addObject("stars",stars);
		modelAndView.addObject("count",count);
		return modelAndView;
	}
	
	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String delete(TzParams params){
		starService.delete(params);
		return "success";
	}
	
	@ResponseBody
	@RequestMapping(value="/update",method=RequestMethod.POST)
	public String update(TzParams params){
		starService.update(params);
		return "success";
	}
}
